package com.mine.framedemo;

import android.os.Bundle;

import com.fgs.common.CommonActivity;
import com.fgs.common.CommonFragment;
import com.fgs.common.CommonPresenter;
import com.fgs.common.CommonView;
import com.fgs.common.appStatus.AppStatusConstant;
import com.fgs.common.appStatus.AppStatusManager;
import com.fgs.common.entity.region.RegionInfo;
import com.fgs.common.utils.LogUtil;
import com.fgs.common.widget.itemView.CitySearchView;
import com.fgs.common.widget.itemView.RegionItemView;
import com.fgs.common.widget.itemView.SelectInputItemView;
import com.xuexiang.xutil.net.JsonUtil;

import butterknife.BindView;

public class MainActivity extends CommonActivity {


    @BindView(R.id.activity_main_regionItemView)
    RegionItemView regionItemView;
    @BindView(R.id.activity_main_selectInputItemView)
    SelectInputItemView selectInputItemView;
    @BindView(R.id.activity_main_citySearchView)
    CitySearchView citySearchView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        AppStatusManager.getInstance().setAppStatus(AppStatusConstant.STATUS_NORMAL);
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    public CommonPresenter createPresenter() {
        return null;
    }

    @Override
    public CommonView createView() {
        return null;
    }

    @Override
    public void init() {

//        DisplayMetrics displayMetrics = new DisplayMetrics();
//        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);      // 获取屏幕的尺寸
//        int width = displayMetrics.widthPixels;                         // 屏幕宽
//        int height = displayMetrics.heightPixels;                       // 屏幕高
//
//        LinearLayout layout = (LinearLayout) findViewById(R.id.layout_horizontal);  // 待旋转布局
//        layout.setLayoutParams(new LinearLayout.LayoutParams(height, width));       // 设置布局的宽和高,必须要和屏幕的反过来
//        layout.setRotation(90);             // 顺时针旋转90度
//        layout.setY((height - width) / 2);
//        layout.setX((width - height) / 2);  // 将布局位移到屏幕中心

        regionItemView.setOnRegionCallback(new RegionItemView.OnRegionSelectedCallback() {
            @Override
            public void regionCallback(RegionInfo info) {
                LogUtil.print(JsonUtil.toJson(info));
            }
        });
        selectInputItemView.setOnSelectItemListener(new SelectInputItemView.OnSelectItemListener() {
            @Override
            public void onSelectClick() {
                showToast("click");
            }
        });

        citySearchView.setOnCitySearchListener(new CitySearchView.OnCitySearchListener() {
            @Override
            public void citySearchCallback(RegionInfo regionInfo) {
                showToast(regionInfo.label);
            }
        });

        citySearchView.setOnCitySearchSelectListener(new CitySearchView.OnCitySearchSelectListener() {
            @Override
            public void onCitySelect(RegionInfo regionInfo) {
                LogUtil.print(JsonUtil.toJson(regionInfo));
            }
        });

    }

    @Override
    public CommonFragment createFragment() {
        return null;
    }
}
